<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/bootstrap.min.css">
    <script src="./js/art-template.js"></script>
    <style>
        * {
            list-style: none;
        }

        ul {
            background-color: pink;

        }

        li {
            height: 30px;
            line-height: 30px;
        }

        li:hover {
            background-color: white;
        }

        #inp {
            border: 2px solid #F03726;
        }
    </style>
</head>

<body>
    <div class="container input-group">
        <input type="text" class="form-control" id="inp">
        <span class="btn  input-group-addon">搜索</span>
    </div>
    <div class="container" id="seacherTpl"></div>
    <script type="text/html" id="sTpl">
        <ul class="container" style="width: 887px;margin-left: 0px;">
            {{each result}}
            <li>{{$value[0]}}</li>
            {{/each}}
        </ul>
    </script>
</body>

</html>
<script src="./js/bootstrap.min.js"></script>
<script src="./js/jquery.js"></script>
<script>
    $('#inp').on('keyup', function () {
        var jp = $(this).val().trim();
        console.log(jp);
        $.ajax({
            type: 'get',
            url: 'https://suggest.taobao.com/sug',
            data: {
                q: jp
            },
            dataType: 'jsonp',
            jsonp: 'callback',
            jsonpCallback: 'success',
            success: function (res) {
                console.log(res);
                var htmlStr = template('sTpl', res);
                $('#seacherTpl').html(htmlStr);
            },
        })
    })
    var suggest = {};
    // 定义防
</script>